<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition template="/WEB-INF/layout.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <h:form>
            <p:panel id="panelExercicio" header="Exercícios">
                <h:panelGrid columns="4" style="margin-bottom:10px; width: 100%" cellpadding="5">
                    <p:outputLabel value="Grupo Muscular:"/>
                    <p:selectOneMenu  value="#{exercicioController.grupoMuscular}">  
                        <f:selectItem itemLabel="Abdome" itemValue="Abdome" />  
                        <f:selectItem itemLabel="Bíceps" itemValue="Bíceps" />  
                        <f:selectItem itemLabel="Costas" itemValue="Costas" />
                        <f:selectItem itemLabel="Coxa/Glúteo" itemValue="Coxa/Glúteo"/>
                        <f:selectItem itemLabel="Peito" itemValue="Peito" />
                        <f:selectItem itemLabel="Perna" itemValue="Perna" />
                        <f:selectItem itemLabel="Ombro" itemValue="Ombro" />
                        <f:selectItem itemLabel="Tríceps" itemValue="Tríceps" />
                        <f:ajax render="exercicios" event="valueChange"/>
                    </p:selectOneMenu>
                    <p:spacer width="400" height="0" />
                    <p:commandButton value="Buscar" actionListener="#{exercicioController.pesquisarExercicio}" update="panelExercicio"/>
                </h:panelGrid>

                <p:dataTable id="exercicios" var="exercicio"
                             value="#{exercicioController.exercicioDM}" 
                             style="width:100%;" 
                             rowKey="#{exercicio.idExercicio}"
                             rows="5"
                             selection="#{exercicioController.exercicioSelecionado}" 
                             selectionMode="single">
                    <p:ajax event="rowSelect" listener="#{exercicioController.onRowSelectExercicio}"/>

                    <p:column headerText="Código">
                        #{exercicio.idExercicio}
                    </p:column>

                    <p:column headerText="Nome">  
                        #{exercicio.nome}  
                    </p:column>  

                    <p:column headerText="Grupo Muscular">  
                        #{exercicio.grupoMuscular}  
                    </p:column>
                </p:dataTable> <br />

                <p:commandButton value="Alterar" action="#{exercicioController.alterarExercicio}" ajax="false"/>
                <p:spacer width="10" height="0"/>
                <p:commandButton value="Excluir" actionListener="#{exercicioController.excluirExercicio}" update="panelExercicio"/>
                <p:spacer width="10" height="0"/>
                <p:commandButton value="Sair" action="/Telas/pesquisarAluno"/>

                <p:dialog id="dialog" header="#{exercicioController.cabecalhoMsg}" widgetVar="exercicioDialog" resizable="false"  
                          showEffect="fade" hideEffect="explode">  
                    <h:panelGrid id="display" columns="2" cellpadding="4"> 
                        <h:outputText value="#{exercicioController.mensagem}" />  
                    </h:panelGrid>  
                </p:dialog>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>